import store from "../store/index"
console.log("store", store)
export function setphone(params) {
  console.log("store", store)
  wx.request({
    url: store.data.globhttp + "UpdateUserInfo",
    method: 'POST',
    header: {
      'content-type': 'application/json',
      "content-type": "application/x-www-form-urlencoded"
    },
    data: JSON.stringify({
      User_Name: store.data.infouser.User_Name,
      User_Id: store.data.infouser.User_Id,
      Token_Code: store.data.isToken,
      User_Tel: store.data.xgphone,
    }),
    success: (res) => {
      console.log(res)
      if (res.data.RltCode == 1) {
        store.data.infouser.Pson_Tel = store.data.xgphone
        console.log("infouser",store.data.infouser)
        wx.setStorageSync('infouser', store.data.infouser)
        wx.switchTab({
          url: '/pages/mine/mine'
        });
      }
    },
    fail: () => {

    }
  })
}

export function setpass(params) {
  console.log("store", store)
  wx.request({
    url: store.data.globhttp + "PsonUserChgPass",
    method: 'POST',
    header: {
      'content-type': 'application/json',
      "content-type": "application/x-www-form-urlencoded"
    },
    data: JSON.stringify({
      OldUserPass: store.data.xgUserPass.OldUserPass,
      User_Id: store.data.infouser.User_Id,
      Token_Code: store.data.isToken,
      NewUserPass: store.data.xgUserPass.NewUserPass,
    }),
    success: (res) => {
      console.log(res)
      if (res.data.RltCode == 1) {
        console.log("infouser",store.data.infouser)
        wx.setStorageSync('infouser', store.data.infouser)
        wx.switchTab({
          url: '/pages/mine/mine'
        });
      }
    },
    fail: () => {

    }
  })
}

export function settjitems(params) {
  console.log("store", store)
  wx.request({
    url: store.data.globhttp + "GetReleaseCheckReports",
    method: 'POST',
    header: {
      'content-type': 'application/json',
      "content-type": "application/x-www-form-urlencoded"
    },
    data: JSON.stringify({
      Begin_Year: store.data.settjitems.startdate,
      User_Id: store.data.infouser.User_Id,
      Token_Code: store.data.isToken,
      End_Year: store.data.settjitems.enddate,
      View_State:store.data.settjitems.View_State
    }),
    success: (res) => {
      console.log(res)
      if (res.data.RltCode == 1) {
             if(store.data.settjitems.View_State==0){
               store.data.settjitems.numList=JSON.parse(res.data.RltData)
             }else if(store.data.settjitems.View_State==1){
              store.data.settjitems.numList1=JSON.parse(res.data.RltData)
             }
      }else if(res.data.RltCode == 0){
        if(store.data.settjitems.View_State==0){
          store.data.settjitems.numList=[]
        }else if(store.data.settjitems.View_State==1){
         store.data.settjitems.numList1=[]
        }
      }
    },
    fail: () => {

    }
  })
}
export function UpdateViewState(params) {
  wx.request({
    url: store.data.globhttp + "UpdateCheckRptViewState",
    method: 'POST',
    header: {
      'content-type': 'application/json',
      "content-type": "application/x-www-form-urlencoded"
    },
    data: JSON.stringify({
      User_Id: store.data.infouser.User_Id,
      Token_Code: store.data.isToken,
      Check_No:store.data.Check_No,
      View_State:"1"
    }),
    success:(res)=>{
       if(res.data.RltCode==1){
         console.log(res.data.RltMsg)
       }
    },
    fail:()=>{

    }
  })
}

export function setAdress(params) {
  wx.request({
    url: store.data.globhttp + "GetGroupInfo",
    method: 'POST',
    header: {
      'content-type': 'application/json',
      "content-type": "application/x-www-form-urlencoded"
    },
    data: JSON.stringify({
      User_Id: store.data.infouser.User_Id,
      Token_Code: store.data.isToken,
    }),
    success:(res)=>{
       if(res.data.RltCode==1){
         console.log(res.data.RltMsg)
         store.data.GroupInfo=JSON.parse(res.data.RltData)
       }
    },
    fail:()=>{

    }
  })
}
export function xxcount(params) {
  wx.request({
    url: store.data.globhttp + "GetCheckReports_Count",
    method: 'POST',
    header: {
      'content-type': 'application/json',
      "content-type": "application/x-www-form-urlencoded"
    },
    data: JSON.stringify({
      User_Id: store.data.infouser.User_Id,
      Token_Code: store.data.isToken,
      Begin_Year:"",
      End_Year:""
    }),
    success:(res)=>{
       if(res.data.RltCode==1){
         console.log(res.data.RltMsg)
         store.data.xxcount=JSON.parse(res.data.RltData)
       }
    },
    fail:()=>{

    }
  })
}